package com.breeze.login;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import brouter.annotation.BRouter;
import brouter.annotation.Parameter;
import brouter.api.ParameterManager;
import brouter.api.RouterManager;

@BRouter(path = "/login/LoginActivity")
public class LoginActivity extends AppCompatActivity {
    @Parameter
    String name;
    @Parameter
    String password;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ParameterManager.bind(this);
    }

    public void startRegisterModule(View view) {
        // 方式一：类加载  缺点：包名容易写错，无其他明显缺点
//        try {
//            Class clz = Class.forName("com.breeze.register.RegisterActivity");
//            startActivity(new Intent(this, clz));
//        } catch (ClassNotFoundException e) {
//            e.printStackTrace();
//        }

        // 方式二：全局Map
       /* Class<?> targetActivity = PathManager.getTargetActivity("register", "RegisterActivity");
        startActivity(new Intent(this, targetActivity));
*/
        // 方式三：自定义BRouter
        RouterManager.getInstance().build("/register/RegisterActivity")
                .withString("name", name)
                .withString("pwd", password)
                .navigation(this);
    }
}
